package com.party.core.model.commune;

import com.google.common.collect.Maps;

import java.util.Map;

/**
 * @program: party
 * @description: 动态类型枚举
 * @author: Hua Qunhao
 * @create: 2019-12-18 16:09
 **/
public enum MomentType {
    SYSTEM_NOTICE(0, "系统通知"),
    MEMBER_JOIN(1, "新会员加入"),
    ACTIVITY_PUBLISH(2, "活动发布"),
    TOPIC_PUBLISH(3, "圈子话题发布"),
    PHOTO_PUBLISH(4, "相册上传"),
    ADD_INTEGRAL(5, "批量添加积分"),
    NEWS(6, "文章");
    //状态码
    private Integer code;

    //状态值
    private String value;

    MomentType(Integer code, String value) {
        this.code = code;
        this.value = value;
    }

    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    public String getValue() {
        return value;
    }

    public void setValue(String value) {
        this.value = value;
    }

    public static String getValue(Integer code){
        for (MomentType momentType : MomentType.values()){
            if (momentType.getCode().equals(code)){
                return momentType.getValue();
            }
        }
        return null;
    }

    public static Map<Integer, String> convertMap(){
        Map<Integer, String> map = Maps.newHashMap();
        for (MomentType momentType : MomentType.values()){
            map.put(momentType.getCode(), momentType.getValue());
        }
        return map;
    }
}
